package com.gizwits.util


import jodd.util.Bits

object UtilBits {
   def byte2bool(data: Array[Byte], offset:Int=0):Int ={if(Bits.getBoolean(data, offset)) 1  else 0}
   def byte2Uint32(data: Array[Byte], offset:Int=0):Int={
      val res=(data(offset) << 24) + (data(offset + 1) << 16) + (data(offset + 2) << 8) + data(offset + 3)
      if(res>=0) res else res+256
   }
   def byte2Uint8(data: Array[Byte], offset:Int=0):Int=data(offset)
   def byte2Uint16(data: Array[Byte], offset:Int=0):Int=(data(offset + 1) << 8) + data(offset + 2)



}
